package com.uestc.soft.controller;

import com.uestc.soft.pojo.Log;
import com.uestc.soft.service.LogService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
public class LogController {

    @Resource
    private LogService logService;

    @RequestMapping("/selectByLogPage")
    public Map<String, Object> selectByLogPage(@RequestParam int page,
                                            @RequestParam int limit,
                                               String level,
                                               String event,
                                            String host,
                                            String state,
                                            String deal) {
        return logService.selectByPage(page, limit, level, event, host, state, deal);
    }

    @RequestMapping("/log/insertLog")
    public Map<String, Object> insertLog(@RequestBody Log log) {
        return logService.insertLog(log);
    }

    @RequestMapping("/log/deleteByLogId")
    public Map<String, Object> deleteByLogId(@RequestParam Integer id) {
        return logService.deleteByLogId(id);
    }

    @RequestMapping("/log/updateDeal")
    public Map<String, Object> updateDeal(@RequestParam Integer id, @RequestParam String deal) {
        return logService.updateDeal(id, deal);
    }
}
